package edu.njucm.herbiv.dao

import edu.njucm.herbiv.pojo.entity.Chemical
import edu.njucm.herbiv.pojo.entity.Formula
import edu.njucm.herbiv.pojo.entity.Protein
import edu.njucm.herbiv.pojo.entity.Tcm
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository

/**
 * @Author ZhouHang
 * @Date 24/5/12 012
 */
@Repository
interface ChemicalRepository: JpaRepository<Chemical, String> {
    override fun findAll(pageable: Pageable): Page<Chemical>
    fun findAllByIdLike(id: String, pageable: Pageable): Page<Chemical>
    fun findAllByNameLike(name: String, pageable: Pageable): Page<Chemical>
    fun findAllBySmilesLike(smiles: String, pageable: Pageable): Page<Chemical>
    fun findAllByCasIdLike(casId: String, pageable: Pageable): Page<Chemical>
    fun findAllByPubChemIdLike(pubChemId: String, pageable: Pageable): Page<Chemical>
    fun findAllByDrugBankIdLike(drugBankId: String, pageable: Pageable): Page<Chemical>
    fun findAllByStitchIdLike(stitchId: String, pageable: Pageable): Page<Chemical>
    fun findAllByHerbIdLike(herbId: String, pageable: Pageable): Page<Chemical>
}

@Repository
interface ProteinRepository: JpaRepository<Protein, String> {
    override fun findAll(pageable: Pageable): Page<Protein>
    fun findAllByIdLike(id: String, pageable: Pageable): Page<Protein>
    fun findAllByProteinNameLike(proteinName: String, pageable: Pageable): Page<Protein>
    fun findAllByGeneNameLike(geneName: String, pageable: Pageable): Page<Protein>
}

@Repository
interface TcmRepository : JpaRepository<Tcm, String> {
    override fun findAll(pageable: Pageable): Page<Tcm>
    fun findAllByIdLike(id: String, pageable: Pageable): Page<Tcm>
    fun findAllByCnNameLike(cnName: String, pageable: Pageable): Page<Tcm>
    fun findAllByEnNameLike(enName: String, pageable: Pageable): Page<Tcm>
    fun findAllByPinyinNameLike(pinyinName: String, pageable: Pageable): Page<Tcm>
    fun findAllByLatinNameLike(latinName: String, pageable: Pageable): Page<Tcm>
    fun findAllByPropertiesLike(properties: String, pageable: Pageable): Page<Tcm>
    fun findAllByMeridiansLike(meridians: String, pageable: Pageable): Page<Tcm>
    fun findAllByUsepartLike(usepart: String, pageable: Pageable): Page<Tcm>
    fun findAllByFunctionLike(function: String, pageable: Pageable): Page<Tcm>
    fun findAllByIndicationLike(indication: String, pageable: Pageable): Page<Tcm>
    fun findAllByToxicityLike(toxicity: String, pageable: Pageable): Page<Tcm>
    fun findAllByClinicalManifestationsLike(clinicalManifests: String, pageable: Pageable): Page<Tcm>
    fun findAllByTherapeuticEnClassLike(enClass: String, pageable: Pageable): Page<Tcm>
    fun findAllByTherapeuticCnClassLike(cnClass: String, pageable: Pageable): Page<Tcm>
    fun findAllByHerbIdLike(herbId: String, pageable: Pageable): Page<Tcm>
    fun findAllByTcmidId(tcmId: String): List<Tcm>
    fun findAllByTcmIdId(tcmId: String): List<Tcm>
    fun findAllBySymmapIdLike(symmapId: String, pageable: Pageable): Page<Tcm>
    fun findAllByTcmspIdLike(tcmspId: String, pageable: Pageable): Page<Tcm>
}


@Repository
interface FormulaRepository : JpaRepository<Formula, String> {
    override fun findAll(pageable: Pageable): Page<Formula>
    fun findAllByIdLike(id: String, pageable: Pageable): Page<Formula>
    fun findAllByNameLike(name: String, pageable: Pageable): Page<Formula>
    fun findAllByInstructionsLike(instructions: String, pageable: Pageable): Page<Formula>
    fun findAllByPrescriptionCompositionLike(composition: String, pageable: Pageable): Page<Formula>
    fun findAllByTreatmentSymptomsLike(symptom: String, pageable: Pageable): Page<Formula>
    fun findAllBySourceDocumentLike(source: String, pageable: Pageable): Page<Formula>
}
